﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DDD4Fun.Mediator
{
    public class Class1
    {
        public Class1()
        {
          
        }

        public void Register()
        {
            MessageMediator.Instance.Register<string>(this, (e) =>
            {
                Console.WriteLine(string.Format("class1 receive1:{0}", e));
            },"dd");
            MessageMediator.Instance.Register<string>(this, (e) =>
            {
                Console.WriteLine(string.Format("class1 receive2:{0}", e));
            }, "ee");
        }

        public void go()
        {
            MessageMediator.Instance.UnRegister<string>(this, "dd");
            MessageMediator.Instance.Send<string>("send by class1");
            MessageMediator.Instance.Send<string,Class2>("send by class1 to Class2");
            MessageMediator.Instance.Send<string>("send by class1 to Class3","class3");
        }
    }
}
